package tsj.ai.alibaba.data.analysis.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author taoshujian
 * @version 1.0
 * @since 2025-11-14 14:27:22
 */
@AllArgsConstructor
@Getter
public enum TextType {
    JSON("```json", "```"),

    PYTHON("```python", "```"),

    SQL("```sql", "```"),

    HTML("```html", "```"),

    MARK_DOWN("```", "```"),

    TEXT(null, null);

    private final String startSign;

    private final String endSign;

    public static TextType getType(TextType origin, String chuck) {
        if (origin == TEXT) {
            for (TextType type : TextType.values()) {
                if (chuck.equals(type.startSign)) {
                    return type;
                }
            }
        }
        else {
            if (chuck.equals(origin.endSign)) {
                return TextType.TEXT;
            }
        }
        return origin;
    }

    public static TextType getTypeByStratSign(String startSign) {
        for (TextType type : TextType.values()) {
            if (startSign.equals(type.startSign)) {
                return type;
            }
        }
        return TextType.TEXT;
    }
}
